package com.woniu.utils;

/**
 * 请求响应工具类
 * @param <T>
 */
public class ResultResponseUtil<T> {
    private int code; // 状态码 200,成功，500:失败，403：无权
    private String msg; // 消息
    private T data; // 数据

    public ResultResponseUtil() {
    }

    public ResultResponseUtil(T data) {
        this(200, "OK");
        this.data = data;
    }

    public ResultResponseUtil(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultResponseUtil(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static final ResultResponseUtil<Void> SUCCESS = new ResultResponseUtil<Void>(200, "OK");
    public static final ResultResponseUtil<Void> NOT_LOGINED = new ResultResponseUtil<Void>(401, "未登录");
    public static final ResultResponseUtil<Void> FORBIDDEN = new ResultResponseUtil<Void>(403, "无权限");
    public static final ResultResponseUtil<Void> FAIL = new ResultResponseUtil<Void>(500, "操作失败");
    public static final ResultResponseUtil<Void> NOT_FOUND = new ResultResponseUtil<Void>(404, "资源未找到");
    public static final ResultResponseUtil<Void> PARAM_INVAILD = new ResultResponseUtil<Void>(400, "提交参数非法");

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
